@extends('layouts.app')
@section('content')
<div class="jumbotron">
  <div class="container">
    <div class="row">
      <div class="col-md-9" role="mian">
        <div class="media">
          <div class="media-left">
            <a href="#">
              <img class="media-object img-circle"  alt="64*64" src="{{ $discussion->user->avatar }}">
            </a>
          </div>
          <div class="media-body">
            <h4 class="media-heading">{{ $discussion->title }}</h4>
            {{ $discussion->user->name }}
          </div>
        </div>
      </div>
      <a class="btn btn-primary btn-lg pull-right" href="#" role="button">修改</a>
    </div>
  </div>
</div>
<div class="container">
  <div class="blog-post">
    <h2 class="blog-post-title">{{ $discussion->title }}</h2>
    <p class="blog-post-meta">January 1, 2014 by <a href="#">Mark</a></p>
    <p>{!! $content !!}</p>
  </div>
  <hr>
  <div class="review">
    <h3>评论</h3>
    @foreach($discussion->comment as $comment)
      <div class="media">
          <div class="media-left">
            <a href="#">
              <img class="media-object img-circle"  alt="64*64" src="{{ $comment->user->avatar }}">
            </a>
          </div>
          <div class="media-body">
            <h4 class="media-heading"><a href="{{ url('post/show/'.$discussion->id) }}">{{ $comment->user->name }}</a></h4>
            {{ $comment->content }}
          </div>
        </div>
    @endforeach
  </div>
  <hr>
  <h3>发表评论</h3>
  @if(Auth::check())
  <form method="post" action=" {{ url('comment/create')}} ">
    {{csrf_field()}}
     <div class="form-group ">
      <input type="hidden" name="discussion_id" value="{{ $discussion->id }}">
      <textarea class="form-control" rows="5" id='myEditor' name="content"></textarea>
      @if ($errors->has('content'))
        <span class="help-block">
            <strong>{{ $errors->first('content') }}</strong>
        </span>
      @endif
    </div>
    <button type="submit" class="btn btn-default pull-right">发表</button>
  </form>
  @else
    <a href="{{ url('login') }}" class="btn btn-block btn-success">登录参与评论</a>
  @endif  
</div>

@endsection

